<template>
  <div class="app-container">
    <div class="one">
      <el-form :inline="true" :model="orderFindByPage" class="demo-form-inline">
        <el-row>
          <el-col :span="4">
            <el-input
              placeholder="请输入用户id"
              v-model="orderFindByPage.lgTourOrder.userId"
              clearable
            >
            </el-input>
          </el-col>
          <el-col :span="4">
            <el-input
              placeholder="请输入订单编号"
              v-model="orderFindByPage.lgTourOrder.productId"
              clearable
            >
            </el-input>
          </el-col>
          <el-col :span="4">
            <el-select
              v-model="orderFindByPage.lgTourOrder.orderStatus"
              placeholder="请输入订单状态"
            >
              <el-option 
              v-for="status in option"
              :key="status.value"
              :label="status.label"
               :value="status.value"></el-option>
              
            </el-select>
          </el-col>
          <el-col :span="4">
            <el-button type="primary" @click="getAllOrderBySearch">查询</el-button>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <br>
    <div class="two">
      <el-row>
        <el-col :span="24">
          <el-table
            :data="tableData"
            style="width: 100%"
            border
            :header-cell-style="{ 'text-align': 'center' }"
            :cell-style="{ 'text-align': 'center' }"
          >
            <el-table-column label="订单编号">
              <template slot-scope="scope">
                <span>{{ scope.row.orderId }}</span>
              </template>
            </el-table-column>
            <el-table-column label="用户id">
              <template slot-scope="scope">
                <span>{{ scope.row.userId }}</span>
              </template>
            </el-table-column>
            <el-table-column label="订单状态">
              <template slot-scope="scope">
                <!-- <span>{{ scope.row.orderPayoutStatus }}</span> -->
                <el-tag v-if="scope.row.orderPayoutStatus == 0">未付款</el-tag>
                <el-tag v-if="scope.row.orderPayoutStatus == 1">已付款</el-tag>
              </template>
            </el-table-column>
            <el-table-column label="订单金额">
              <template slot-scope="scope">
                <span>{{ scope.row.orderAmount}}</span>
              </template>
            </el-table-column>
            <el-table-column label="支付金额">
              <template slot-scope="scope">
                <span>{{ scope.row.orderAmount }}</span>
              </template>
            </el-table-column>
            
            <el-table-column label="操作">
              <template slot-scope="scope">
                
                  <el-button
                    size="mini"
                    type="danger"
                    @click="handleFindOrder(scope.$index, scope.row)"
                    >详情</el-button
                  >
                
                
              </template>
              
            </el-table-column>
          </el-table>
          <el-pagination
            :current-page="currentPage"
            :page-sizes="[2, 5, 8, 10]"
            :page-size="10"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            style="margin-top: 30px; margin-bottom: 20px; text-align: center;"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            />
        </el-col>
      </el-row>
      <el-dialog :title="title" :visible.sync="dialogFormVisible">
      <el-form :model="form">
        <el-form-item label="学员姓名" :label-width="formLabelWidth">
          <el-input v-model="form.userName" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="部门" :label-width="formLabelWidth">
          <el-select v-model="form.deptId" placeholder="请选择">
            <el-option
              v-for="item in options1"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="职位" :label-width="formLabelWidth">
          <el-input v-model="form.userPosition" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="联系方式" :label-width="formLabelWidth">
          <el-input v-model="form.userTelephone" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="邮箱" :label-width="formLabelWidth">
          <el-input v-model="form.userEmail" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="经理" :label-width="formLabelWidth">
          <el-input v-model="form.userManager" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="角色" :label-width="formLabelWidth">
          <el-select v-model="form.userRole" placeholder="请选择">
            <el-option
              v-for="role in options2"
              :key="role.value"
              :label="role.label"
              :value="role.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="submit('form')">确 定</el-button>
      </div>
    </el-dialog>
    </div>
  </div>
</template>

<script>
import { getAllOrder } from '@/api/order'

export default {
  data() {
    return {
      option:[
        {
          value: "0",
          label: "未出行",
        },
        {
          value: "1",
          label: "进行中",
        },
        {
          value: "2",
          label: "已完成",
        }
      ],
      orderFindByPage: {
          page: 1,
          limit: 10,
          lgTourOrder:{
            userId: "",
            productId: "",
            orderStatus: ""
          }
      },
      tableData: [],
      formInLine: {
        page: 1,
        limit: 10,
        id: 0
      },
       total: 0,
      number: 0,
      currentPage: 1,
      title:"详情",
      dialogFormVisible: false,
      formLabelWidth: "120px",
      form:{
        orderId:"",
        orderPayoutStatus:"",
        userId:"",
        
      }
    };
  },
  created(){
      this.getAllOrderBySearch()
  },

  methods: {
    getAllOrderBySearch(){
        getAllOrder(this.orderFindByPage)
        .then((res) => {
          console.log(res);
            this.tableData = res.data.list;
            this.total = res.data.total;
            this.currentPage = res.data.currentPage;
        }).catch((err) => {
          
      })
    },
    handleSizeChange(val) {
      this.orderFindByPage.limit = val;
      getAllOrder(this.orderFindByPage).then((res) => {
        console.log(res);
        this.tableData = res.data.list;
        this.currentPage = res.data.pageNum;
      });
    },
    handleCurrentChange(val) {
      this.orderFindByPage.page = val;
      getAllOrder(this.orderFindByPage).then((res) => {
        console.log(res);
        this.tableData = res.data.list;
        this.currentPage = res.data.pageNum;
      });
      console.log(`当前页: ${val}`);
    },
    handleFindOrder(index, row){
      // this.dialogFormVisible = true;
      console.log(row);

    }
  }
  
};
</script>

<style >
</style>

